﻿

--划百度客户
CREATE PROCEDURE [dbo].[proc_BCustomer_Paddle]
	(
		@CusId varchar (4000),
		@CusName nvarchar(50),
		@UserName nvarchar(50),
		@EName nvarchar(50),
		@CreateName nvarchar(50)
	)

AS

	BEGIN	
		
		declare @str NVARCHAR (max),@str1 NVARCHAR (max)
		
		set @str='
		
		
		--更改成单表 百度                
		update [Order] set trackBDAccount='''+@UserName+''',trackBDName='''+@EName+'''
		where cusid in (  '+@CusId+'  )            
		
		
		--更新客户表
		update customer set BDServicePerson='''+@UserName+''',BDServicePersonEName='''+@EName+''',BDServiceDate=getdate()
		where CustomerId in ('+@CusId+')'
		
		set @str1='

		--插入日志表
		Insert Into Customer_HuaTemp(CusId,CusName,UserName,EName,CreateName,CreateDate,CusInfo,flag) 
		select CustomerId,CustomerName,'''+@UserName+''','''+@EName+''','''+@CreateName+''',getdate(),
		''[''+BDServicePerson+''],[''+BDServicePersonEName+''],[''+ISNULL(Convert(varchar,BDServiceDate,120),'''')+'']'',2
		 from Customer where CustomerId in ('+@CusId+') 
		 '
		 exec(@str)
		 exec(@str1)
		-- print (@str) 		
	End
	
	RETURN

